sap.ui.define([
    "jquery.sap.global", "sap/ui/core/Fragment", "sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel"
], function(jQuery, Fragment, Controller, JSONModel) {

    "use strict";

    var Controller = Controller.extend("sap.lx.shell", {
        onInit: function() {
            var model = new JSONModel({
                apps: [
                    {
                        title: "Recent Maths",
                        pressAction: {
                            type: "url",
                            url: "./nba/#/match"
                        }
                    }, {
                        title: "Team Range",
                        pressAction: {
                            type: "url",
                            url: "./nba/#/range"
                        }
                    }, {
                        title: "Team List",
                        pressAction: {
                            type: "url",
                            url: "./nba/#/team"
                        }
                    }, {
                        title: "Man List",
                        pressAction: {
                            type: "url",
                            url: "./nba/#/man"
                        }
                    }, {
                        title: "User Controll",
                        pressAction: {
                            type: "url",
                            url: "./nba/#/user"
                        }
                    }
                ]
            });

            this.getView().setModel(model, "apps");
            this.model_apps = model;
        },
        onTilePress: function(event) {

            var tile = event.getSource();
            var context = tile.getBindingContext("apps");
            var action = this.model_apps.getProperty(context + "/pressAction");
            if (action.type === "url") {

                var url = action.url;
                window.location = url;

            }

        },
        getRouter: function() {
            return sap.ui.core.UIComponent.getRouterFor(this);
        }

    });

    return Controller;

});
